﻿using Microsoft.AspNetCore.Mvc;
using Shop.Core.Share;
using Shop.IServices.Admin;
using Shop.Model.Dto.Admin.NewProduct;
using Shop.Model.View.Admin.NewProduct;

namespace Shop.AdminApi.Controllers;

/// <summary>
/// 新品服务
/// </summary>
[ApiController]
[Route("admin/[controller]")]
public class NewProductController: ShopControllerBase
{
    private readonly INewProductService _newProductService;

    /// <summary>
    /// 
    /// </summary>
    /// <param name="newProductService"></param>
    public NewProductController(INewProductService newProductService)
    {
        _newProductService = newProductService;
    }

    /// <summary>
    /// 新品列表
    /// </summary>
    /// <param name="dto"></param>
    /// <returns></returns>
    [HttpGet("NewProductList")]
    public AppResult<PageModel<NewProductListVo>> NewProductList([FromQuery] NewProductListDto dto)
        => _newProductService.NewProductList(dto);

    /// <summary>
    /// 新品详情
    /// </summary>
    /// <param name="dto"></param>
    /// <returns></returns>
    [HttpGet("NewProductInfo")]
    public AppResult<NewProductInfoVo> NewProductInfo([FromQuery] long dto)
        => _newProductService.NewProductInfo(dto);

    /// <summary>
    /// 新品编辑
    /// </summary>
    /// <param name="dto"></param>
    /// <returns></returns>
    [HttpPost("NewProductEdit")]
    public AppResult NewProductEdit(NewProductEditDto dto)
        => _newProductService.NewProductEdit(dto);

    /// <summary>
    /// 添加新品
    /// </summary>
    /// <param name="dto"></param>
    /// <returns></returns>
    [HttpPost("NewProductAdd")]
    public AppResult NewProductAdd(NewProductAddDto dto)
        => _newProductService.NewProductAdd(dto);
    
    /// <summary>
    /// 激活新品
    /// </summary>
    /// <param name="dto"></param>
    /// <returns></returns>
    [HttpGet("NewProductEnable")]
    public AppResult NewProductEnable([FromQuery]long dto)
        => _newProductService.NewProductEnable(dto);
}